<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class search_model extends CI_Model
{
	
	public function __construct()
	{
		parent::__construct();
		$data=array();

	} 	
		
public function getbranch_product($id){
	
	$this->db->select('branch_product.*, branch.name as branch_name, product.name AS product_name, product.code AS product_code,category.name AS category_name, company.name AS company_name');
	$this->db->from('branch_product', 'product', 'company', 'category','branch');
	$this->db->join('branch', 'branch_product.id_branch= branch.id');
	$this->db->join('product', 'branch_product.id_product= product.id');
	$this->db->join('category', 'product.id_category =  category.id');
	$this->db->join('company', 'product.id_company= company.id');
	$this->db->where('branch_product.id_product',$id);
	//$this->db->join('company', 'product.id_company= company.id');
	$result = $this->db->get();
	return $result->result();
	//return $result;	
}

public function product_details($id){
	
	
	$this->db->select('product.*, category.name AS category_name, company.name AS company_name');
	$this->db->from('product', 'company', 'category');
	$this->db->join('category', 'product.id_category= category.id');
	$this->db->join('company', 'product.id_company= company.id');
	$this->db->where('product.id',$id);
	$result = $this->db->get();
	return $result->row();
	
}


}
